#pragma once

#include "neighborhood.h"
#include <string>
using namespace std;

class UnitInstance
{
private:
	Neighborhood feature;			//!< The array of neighborhood, 0 is the central cell, 1 is up left, rotating clockwise.
	int label;						//!< The label for the instance. Is usually either 0 or 1 (black or white)
	int occurrenceNum;				//!< Tells how many times this instant is repeated in a rule base. is 0 for a stand-alone instance.
	int conflictNum;				//!< Tells the number of instances that conflict this instance.
	unsigned long featureHash;		//!< Converts the feature vector to an integer.

	void updateFeatureHash (void);	//!< re-calculates the featureHash data member.


public:
	int getFeature (int);
	int getLabel (void);
	int getOccuranceNum (void);
	int getConflictNum (void);
	unsigned long getHash (void);	//!< Returns the "featureHash" data member.

	void setFeature (int, int);
	void setLabel (int);
	void setOccurrenceNum (int);
	void incrementOccurrenceNum (void);
	void setConflictNum (int);
	void incrementConflictNum (void);
	UnitInstance & operator= (UnitInstance&);	//!< Assignment operator
	bool hasSameFeature (UnitInstance&);		//!< Returns true if the feature array of both objects have the same elements.
	void print(void);							//!< Prints the feature array to the screen
	void printDetail(void);						//!< Prints all the member data to the screen


	UnitInstance ();

	UnitInstance (string,  int);	//!< Creates the object from a provided string and a label
	UnitInstance (int*, int);		//!< Creates the object from a provided character array whose pointer is given, and a label
	UnitInstance(int hashValue, int label);	//!< Creates the object from a provided hashValue. The base is CELLSTATES and the length of the array is NEIGHBORHOODSIZE
	UnitInstance(int hashValue, int label, int occurance); //!< Similar to above, but also receives the occuranceNum.

	~UnitInstance();
};

